<?php

namespace JLPay\Models\Trans\Mini\Wx;

use JLPay\Models\BaseRequest;

/**
 * 微信授权绑定请求模型
 */
class AuthBindRequest extends BaseRequest
{
    /**
     * @var string|null 商户号
     */
    private ?string $mchId = null;

    /**
     * @var string|null 交易类型
     */
    private ?string $payType = null;

    /**
     * @var string|null JSAPI支付授权目录
     */
    private ?string $jsapiPath = null;

    /**
     * @var string|null 公众账号ID
     */
    private ?string $subAppid = null;

    /**
     * @var string|null 终端IP
     */
    private ?string $mchCreateIp = null;

    /**
     * 获取API路径
     *
     * @return string API路径
     */
    public function getApiPath(): string
    {
        return '/open/trans/authbind';
    }

    /**
     * 设置商户号
     *
     * @param string $mchId 商户号
     * @return $this
     */
    public function setMchId(string $mchId): self
    {
        $this->mchId = $mchId;
        return $this;
    }

    /**
     * 获取商户号
     *
     * @return string|null 商户号
     */
    public function getMchId(): ?string
    {
        return $this->mchId;
    }

    /**
     * 设置交易类型
     *
     * @param string $payType 交易类型
     * @return $this
     */
    public function setPayType(string $payType): self
    {
        $this->payType = $payType;
        return $this;
    }

    /**
     * 获取交易类型
     *
     * @return string|null 交易类型
     */
    public function getPayType(): ?string
    {
        return $this->payType;
    }

    /**
     * 设置JSAPI支付授权目录
     *
     * @param string $jsapiPath JSAPI支付授权目录
     * @return $this
     */
    public function setJsapiPath(string $jsapiPath): self
    {
        $this->jsapiPath = $jsapiPath;
        return $this;
    }

    /**
     * 获取JSAPI支付授权目录
     *
     * @return string|null JSAPI支付授权目录
     */
    public function getJsapiPath(): ?string
    {
        return $this->jsapiPath;
    }

    /**
     * 设置公众账号ID
     *
     * @param string $subAppid 公众账号ID
     * @return $this
     */
    public function setSubAppid(string $subAppid): self
    {
        $this->subAppid = $subAppid;
        return $this;
    }

    /**
     * 获取公众账号ID
     *
     * @return string|null 公众账号ID
     */
    public function getSubAppid(): ?string
    {
        return $this->subAppid;
    }

    /**
     * 设置终端IP
     *
     * @param string $mchCreateIp 终端IP
     * @return $this
     */
    public function setMchCreateIp(string $mchCreateIp): self
    {
        $this->mchCreateIp = $mchCreateIp;
        return $this;
    }

    /**
     * 获取终端IP
     *
     * @return string|null 终端IP
     */
    public function getMchCreateIp(): ?string
    {
        return $this->mchCreateIp;
    }

    /**
     * 转换为数组格式
     *
     * @return array 数组格式的数据
     */
    public function toArray(): array
    {
        $data = parent::toArray();
        $data = array_merge($data, [
            'mch_id' => $this->mchId,
            'pay_type' => $this->payType,
            'jsapi_path' => $this->jsapiPath,
            'sub_appid' => $this->subAppid,
            'mch_create_ip' => $this->mchCreateIp
        ]);

        return $data;
    }
} 